using System;
using Cysharp.Threading.Tasks;
using JetBrains.Annotations;

namespace EventBus
{
    public partial class EventBusImpl
    {
        private void RemoveListen([NotNull] string eventName, [NotNull] object callback)
        {
            if (string.IsNullOrEmpty(eventName))
                throw new ArgumentException("Value cannot be null or empty.", nameof(eventName));
            if (callback == null) throw new ArgumentNullException(nameof(callback));
            
            var listener = GetOrCreateBroadcast(eventName);
            var count = listener.RemoveListener(eventName, callback);
            if (count == 0)
                RemoveBroadcast(eventName);

        }
        public void RemoveListen([NotNull] string eventName, [NotNull] Action callback)
        {
            RemoveListen(eventName, (object)callback);
        }
        public void RemoveListen<T1>([NotNull] string eventName, [NotNull] Action<T1> callback)
        {
            RemoveListen(eventName, (object)callback);
        }
        public void RemoveListen<T1, T2>([NotNull] string eventName, [NotNull] Action<T1, T2> callback)
        {
            RemoveListen(eventName, (object)callback);
        }
        public void RemoveListen<T1, T2, T3>([NotNull] string eventName, [NotNull] Action<T1, T2, T3> callback)
        {
            RemoveListen(eventName, (object)callback);
        }
        public void RemoveListen<T1, T2, T3, T4>([NotNull] string eventName, [NotNull] Action<T1, T2, T3, T4> callback)
        {
            RemoveListen(eventName, (object)callback);
        }
        public void RemoveListen<T1, T2, T3, T4, T5>([NotNull] string eventName, 
            [NotNull] Action<T1, T2, T3, T4, T5> callback)
        {
            RemoveListen(eventName, (object)callback);
        }
        public void RemoveListen<T1, T2, T3, T4, T5, T6>([NotNull] string eventName, 
            [NotNull] Action<T1, T2, T3, T4, T5, T6> callback)
        {
            RemoveListen(eventName, (object)callback);
        }
        public void RemoveListen<T1, T2, T3, T4, T5, T6, T7>([NotNull] string eventName, 
            [NotNull] Action<T1, T2, T3, T4, T5, T6, T7> callback)
        {
            RemoveListen(eventName, (object)callback);
        }
        public void RemoveListen<T1, T2, T3, T4, T5, T6, T7, T8>([NotNull] string eventName, 
            [NotNull] Action<T1, T2, T3, T4, T5, T6, T7, T8> callback)
        {
            RemoveListen(eventName, (object)callback);
        }
        
    }
}